package com.example.spinning.service;

import com.example.spinning.bean.DailyReport;
import com.example.spinning.bean.QualityReport;
import com.example.spinning.mapper.DailyReportMapper;
import com.example.spinning.mapper.QualityReportMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Date;
import java.sql.Timestamp;
import java.util.List;


@Service
@Transactional
public class QualityReportService {
    @Autowired
    QualityReportMapper qualityReportMapper;




    //增加操作
    public int addNewQualityReport(QualityReport qualityReport) {
        return qualityReportMapper.addNewQualityReport(qualityReport);
    }

    //删除操作
    public boolean deleteQualityReportById(Long[] ids) {
        int result = qualityReportMapper.deleteQualityReportById(ids);
        return result == ids.length;
    }
    //查询并分页
    public PageInfo<QualityReport> findPage(Integer page, Integer size, Long batch_no, String name, String client, Date date) {

        QualityReport qualityReport = new QualityReport();
        qualityReport.setBatch_no(batch_no);
        qualityReport.setName(name);
        qualityReport.setClient(client);
        qualityReport.setDate(date);

        PageHelper.startPage(page,size);
        List<QualityReport> list = qualityReportMapper.select(qualityReport);
        PageInfo<QualityReport> pageInfo = new PageInfo<>(list);

        return pageInfo;
    }
    //动态修改
    public int updateCategoryById(QualityReport qualityReport){
        int result = qualityReportMapper.updateByPrimaryKeySelective(qualityReport);
        return result;
    }


}




